package weak_20241227_29.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zdl
 * @date 2024/12/27
 */
class Employee{
    private String name;
    private Integer age;

    public Employee() {
    }

    public Employee(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public Integer getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(Integer age) {
        this.age = age;
    }

    public String toString() {
        return "Employee{name = " + name + ", age = " + age + "}";
    }
}
public class Demo14 {
    public static void main(String[] args) {
        //14. 从员工（姓名、年龄）列表中找出年龄大于30岁的员工姓名列表
        ArrayList<Employee> list = new ArrayList<>();
        list.add(new Employee("张三", 24));
        list.add(new Employee("李四", 34));
        list.add(new Employee("王五", 21));
        list.add(new Employee("赵六", 38));
        list.add(new Employee("天天", 56));
        list.add(new Employee("看看", 43));
        list.add(new Employee("滋滋", 30));
        list.add(new Employee("看来", 23));
        List<Employee> collect = list.stream().filter(s -> s.getAge() > 30).collect(Collectors.toList());
        System.out.println(collect);
    }
}
